package com.learn.spring5.testdemo;

import org.junit.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.learn.spring5.Book;
import com.learn.spring5.Orders;
import com.learn.spring5.User;
import com.learn.spring5.service.UserService;

public class TestSpring5
{
	@SuppressWarnings("resource")
	@Test
	public void testAdd()
	{
		// 1 加载spring配置文件
		ApplicationContext context = new ClassPathXmlApplicationContext("bean1.xml");
		// BeanFactory context = new
		// ClassPathXmlApplicationContext("bean1.xml");

		// 2获取配置创建的对象
		User user = context.getBean("user", User.class);
		System.out.println(user);
		user.add();
	}

	@Test
	public void testBook()
	{
		@SuppressWarnings("resource")
		ApplicationContext context = new ClassPathXmlApplicationContext("bean1.xml");
		Book book = context.getBean("book", Book.class);
		book.bookTest();
	}

	@Test
	public void testOrders()
	{
		@SuppressWarnings("resource")
		ApplicationContext context = new ClassPathXmlApplicationContext("bean1.xml");
		Orders orders = context.getBean("orders", Orders.class);
		orders.ordersTest();
	}

}
